/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.report.deposit;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import src.DBManager;
import src.domain.deposit.Bilyet;
import src.report.AbstractBaseReportBean;
import src.view.system.CompanyBean;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
@ManagedBean
@SessionScoped

public class RptBilyetsimBean extends AbstractBaseReportBean{
    private final String COMPILE_FILE_NAME = "deposit/rptBilyetsim";
    
    private List<Bilyet> sim;
    private Date bilyetDate;
    private String productName;    
    private BigDecimal principalAmount;
    private BigDecimal interestRate;
    private BigDecimal interest;
            
    @Override
    protected JRDataSource getJRDataSource() {
        RptBilyetsimDS ds = new RptBilyetsimDS(sim);
        return ds;
    }

    @Override
    protected String getCompileFileName() {
        return COMPILE_FILE_NAME;
    }
    
    public String execute(List<Bilyet> sim) {
	try {
            super.getReportParameters().put("p_bilyetdate", this.bilyetDate);
            super.getReportParameters().put("p_product_name", this.productName);
            super.getReportParameters().put("p_principal_amount", this.principalAmount);
            super.getReportParameters().put("p_interest_rate", this.interestRate);
            super.getReportParameters().put("p_interest", this.interest);
            super.getReportParameters().put("p_company", new CompanyBean().loadCompanyInfo().toString());
            DBManager db = new DBManager();
            db.getConnection();
            super.getReportParameters().put("REPORT_CONNECTION", db.conn);
            this.sim = sim;
            super.prepareReportViaConn(getJRDataSource());
            db.putConnection();
            //super.prepareReport();
	} catch (JRException | IOException e) {}
	
        return null;
    }

    public List<Bilyet> getSim() {
        return sim;
    }

    public void setSim(List<Bilyet> sim) {
        this.sim = sim;
    }

    public BigDecimal getInterestRate() {
        return interestRate;
    }

    public void setInterestRate(BigDecimal interestRate) {
        this.interestRate = interestRate;
    }

    public Date getBilyetDate() {
        return bilyetDate;
    }

    public void setBilyetDate(Date bilyetDate) {
        this.bilyetDate = bilyetDate;
    }

    public BigDecimal getInterest() {
        return interest;
    }

    public void setInterest(BigDecimal interest) {
        this.interest = interest;
    }

    
    public BigDecimal getPrincipalAmount() {
        return principalAmount;
    }

    public void setPrincipalAmount(BigDecimal principalAmount) {
        this.principalAmount = principalAmount;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }
    
    
}
